from fastapi import FastAPI
from fastapi.responses import FileResponse
from fastapi.staticfiles import StaticFiles
import uvicorn

from langchain.schema import HumanMessage, SystemMessage
from langchain.chat_models.gigachat import GigaChat
from langchain.prompts import ChatPromptTemplate
from langserve import add_routes
from config import GIGA_KEY


app = FastAPI()

model = GigaChat(credentials=config("GIGA_KEY"), verify_ssl_certs=False)
prompt = ChatPromptTemplate.from_template("Give me a summary about {topic} in a paragraph or less.")
chain = prompt | model

add_routes(app, chain, path="/")

if __name__ == "__main__":

    uvicorn.run(app, host="0.0.0.0", port=8000)


